﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DisplayBoardInfo.Network;

namespace DisplayBoardInfo.TestClient
{
    class Program
    {
        private static DisplayBoardInfo.Network.Client c;

        static void Main()
        {
            Console.ReadLine();
            c = new Network.Client();
            c.MessageRecived += new Network.Client.MessageRecivedHandler(c_MessageRecived);

            c.Connect("192.168.1.101");

            Console.Write("Username: ");
            string username = Console.ReadLine();
            Console.Write("Password");
            string password = Console.ReadLine();

            Network.Messages.Content.Hello hello = new Network.Messages.Content.Hello();
            hello.Username = username;
            hello.Password = password;
            c.Send(new Network.Messages.NetworkMessage(Network.Messages.NetworkMessageTypes.Hello, hello));
        }

        static void c_MessageRecived(object sender, DisplayBoardInfo.Network.MessageEventArgs args)
        {
            if (args.Message.Type == DisplayBoardInfo.Network.Messages.NetworkMessageTypes.Hello)
            {
                Console.WriteLine("Zalogowany");
            }
            else
            {
                Console.WriteLine(args.Message.Content.ToString());
            }
        }
    }
}
